<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <h2>Essential Links</h2>
    <router-view class="aaa"></router-view>
  </div>
</template>

<script>
import axios from 'axios'
import qs from 'qs'
export default {
  name: 'hi',
  data () {
    return {
      msg: 'Welcome to Your hi.vue'
    }
  },
  methods: {
    test(){
      let _self = this;
      axios.get('http://tp.cn/tp5/point').then(function (response) {
        console.log(response.data);
        _self.msg = response.data.name;
      }).catch(function (error) {
        console.log(error);
      });
    },
    post(){
      let data = {
        firstName: 'Fred',
        lastName: 'Flintstone'
      };
      axios.post('http://tp.cn/tp5/point',data)
      .then(function (response) {
        console.log(response.data);
      })
      .catch(function (error) {
          console.log(error);
      });
    },
    put(){
      let data = {
        firstName: 'Fred',
        lastName: 'Flintstone'
      };
      axios.put('http://tp.cn/tp5/point/1',qs.stringify(data))
      .then(function (response) {
        console.log(response.data);
      })
      .catch(function (error) {
          console.log(error);
      });
    },
    delete(){
      let data = {
        firstName: 'Fred',
        lastName: 'Flintstone'
      };
      axios.delete('http://tp.cn/tp5/point/sdddd',{data:data})
      .then(function (response) {
        console.log(response.data);
      })
      .catch(function (error) {
          console.log(error);
      });
    },
  },
  mounted() {
      // this.test();
      // this.post();
      this.put();//请求的时候加ID
      this.delete();
  },
}
</script>